package com.sk.trans.controller;

import com.sk.trans.service.LogInfoService;
import com.sk.trans.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user2")
@RestController
public class UserInfoController2 {

    @Autowired
    private UserService userService;
    @Autowired
    private LogInfoService logInfoService;

    @Transactional
    @RequestMapping("/register")
    public boolean register(String userName,String password){
        Integer result = userService.insert(userName, password);
        System.out.println("插入用户表,result: "+ result);
        //插入日志表，此处理应在service层实现
        Integer logResult = logInfoService.insert(userName, "用户注册");
        System.out.println("插入日志表,result: "+ result);


        return true;

    }

}
